Skip to content

fix: save staged edits for rows loaded via infinite scroll - #1545

Merged
sorenbs merged 2 commits into
mainfrom
fix/1466-infinite-scroll-save
Jul 18, 2026
Merged

fix: save staged edits for rows loaded via infinite scroll#1545
sorenbs merged 2 commits into
mainfrom
fix/1466-infinite-scroll-save

Conversation

@sorenbs

@sorenbs sorenbs commented Jul 18, 2026

Copy link
Copy Markdown
Member

Fixes #1466

Root cause

With infinite scroll enabled the grid queries pageIndex: 0 with a growing window (pageSize = 25 × loadedBatches), but the row-mutation hooks derived their TanStack DB collection scope independently from usePagination()'s paginated page state. The scopes coincide for the first 25 rows — exactly why the reporter only saw failures for rows that "wouldn't show on the first page". Beyond that, collection.update() threw UpdateKeyNotFoundError with no error surface, so saving silently did nothing.

Fix

ActiveTableView now builds one memoized set of query props (infinite-scroll-aware page window, sort, filter, search) shared by the query hook and all mutation hooks (insert/update/updateMany/delete via selection), which resolve their collection through a new useActiveTableQueryCollection(props) — guaranteeing mutations target exactly the collection the grid displays. Also removes a redundant duplicate table fetch the old hooks triggered. The contract is documented in Architecture/db-state.md.

Verification

  • Reproduced live in the demo (infinite scroll on → load 50 rows → edit row 30 → save → silent no-op) and verified fixed (save toast, value persists across refresh; delete of row 45 also works).
  • New regression test: 50-row infinite window, edits row index 30, asserts persistence through the adapter.
  • Full ui suite 625/625 passing; typecheck/lint clean; changeset included.

🤖 Generated with Claude Code

With infinite scroll enabled, the grid queries pageIndex 0 with a grown
pageSize window (25-row batches), but the row mutation hooks resolved
their TanStack DB collection from the paginated pageIndex/pageSize. The
two query scopes diverge once more than one batch is loaded, so
collection.update() targeted a collection missing rows beyond the first
batch and threw UpdateKeyNotFoundError, making "Save n rows" fail
silently (issue #1466).

The mutation hooks (update, updateMany, delete, insert) now receive the
view's exact query props and resolve their collection through the new
useActiveTableQueryCollection hook, so mutations always target the same
collection scope the grid displays — including the search term
dimension that was previously omitted as well.

Verified end-to-end in the ppg demo: editing and deleting rows beyond
the first 25-row batch with infinite scroll enabled now persists and
shows the success toast.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 26 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a7c154a2-fb86-405f-8000-f934375085c0

📥 Commits

Reviewing files that changed from the base of the PR and between 1669e72 and c56ccc0.

📒 Files selected for processing (5)
  • Architecture/db-state.md
  • ui/hooks/use-active-table-update.ts
  • ui/studio/views/table/ActiveTableView.tsx
  • ui/studio/views/table/infinite-scroll.test.ts
  • ui/studio/views/table/infinite-scroll.ts

Walkthrough

The active table view now creates one memoized query scope and passes it to fetching, selection, insertion, and row mutation hooks. A shared collection hook resolves the active table and collection from that scope, including infinite-scroll batch windows. Update, bulk update, delete, and insert operations use the resolved collection. Tests cover editing a row beyond the first 25-row batch, and documentation describes the mutation-scope rule.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main fix: saving staged edits for rows loaded through infinite scroll.
Description check ✅ Passed The description directly explains the bug, fix, and verification steps for the same infinite-scroll save issue.
Linked Issues check ✅ Passed The changes address #1466 by aligning mutation and view query scopes so edits on scrolled-in rows persist correctly.
Out of Scope Changes check ✅ Passed The extra docs, tests, and refactorings are all tied to the infinite-scroll mutation-scope fix and not unrelated scope.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1466-infinite-scroll-save
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/1466-infinite-scroll-save

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Compute preview deployed.

Branch: fix/1466-infinite-scroll-save
Service: fix-1466-infinite-scroll-save
Preview: https://kl6u0vi0dp3vw3pbegh0772i.cdg.prisma.build

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.

Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.

👉 Steps to fix this

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ui/hooks/use-active-table-update.ts`:
- Around line 12-15: Update the useActiveTableUpdate flow, including its
collection.update transaction, to propagate params.options as
AdapterUpdateOptions when persistence is delegated to the collection. Ensure
callers’ update options remain effective throughout the transaction, or
explicitly remove options from the public API and migrate all callers
consistently.

In `@ui/studio/views/table/ActiveTableView.tsx`:
- Around line 212-240: Align mutation query props with the stable visibleData
during infinite-scroll load-more: do not let loadedInfinitePageCount immediately
redirect mutations to the expanded collection while the prior window is still
displayed. Either atomically update visibleData and mutation props after the
expanded query finishes, or disable save/delete mutations while that query is
fetching. Add coverage for saving during this transition, using
activeTableQueryProps, visibleData, and the affected mutation handlers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4aa9bf77-df4b-4eaa-9cf6-0fc26da75952

📥 Commits

Reviewing files that changed from the base of the PR and between 81354ff and 1669e72.

📒 Files selected for processing (12)
  • .changeset/tidy-lions-tap.md
  • Architecture/db-state.md
  • FEATURES.md
  • ui/hooks/use-active-table-delete.ts
  • ui/hooks/use-active-table-insert.ts
  • ui/hooks/use-active-table-query.ts
  • ui/hooks/use-active-table-update-many.test.tsx
  • ui/hooks/use-active-table-update-many.ts
  • ui/hooks/use-active-table-update.ts
  • ui/hooks/use-selection.test.tsx
  • ui/hooks/use-selection.ts
  • ui/studio/views/table/ActiveTableView.tsx

Comment thread ui/hooks/use-active-table-update.ts
Comment thread ui/studio/views/table/ActiveTableView.tsx
- useActiveTableUpdate: drop the ignored AdapterUpdateOptions/table params
  from UseActiveTableUpdateParams. Persistence is delegated to the rows
  collection's onUpdate handler, so a per-call options channel could never
  reach the adapter; removing it makes that explicit instead of silently
  ignoring the values (API migration; the hook has no product callers).

- ActiveTableView: keep row mutations targeting the visible window during
  infinite-scroll growth. While a grown window is fetching, the grid keeps
  showing the previous settled window; mutation query props now stay pinned
  to that settled window and swap to the grown scope atomically together
  with the rows (new resolveVisibleTableWindow helper + tests), closing the
  save/delete race during the transition.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sorenbs
sorenbs merged commit 3fec72a into main Jul 18, 2026
3 checks passed
@sorenbs
sorenbs deleted the fix/1466-infinite-scroll-save branch July 18, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bugs (regression): scroll in the Prisma Studio Page and save changes

1 participant